import router from "."
//动态添加路由
export function generateRoutes(_asyncRoutes) {
    console.log("111111111111111111111111111111111")
    // const _asyncRoutes = localStorage.getItem("menuList")
     console.log(_asyncRoutes+"2222")
    if(_asyncRoutes==null)
        return
    _asyncRoutes.forEach(menu => {
        if (menu.subMenus) {
            menu.subMenus.forEach(m => {
                let route = menuToRoute(m, menu.menuName);
                if (route) {
                    router.addRoute("home",route)
                }
            })
        }
    })
    console.log(router.routes)
}
 
//将菜单转换成router可以识别的路由
const menuToRoute = (menu) => {
   	let routerInfo={
		path:menu.menuUrl,
		name:menu.menuName,
		meta:{
			title:menu.menuName,
			},
		}
		// routerInfo.component=() => import(/* @vite-ignore */`@views${menu.menuUrl}.vue`)
        routerInfo.component=() => import(/* @vite-ignore */`../views${menu.menuUrl}.vue`)
         return routerInfo;
    
}